const STYLE_OFFSET_FOLD: number = 1;
export const STYLE_MASK_FOLD: number = 1 << STYLE_OFFSET_FOLD;

export const ELEMENT_STYLE_OFFSET_ITALIC = 1;
export const ELEMENT_STYLE_OFFSET_STRIKETHROUGH = ELEMENT_STYLE_OFFSET_ITALIC + 1;
export const ELEMENT_STYLE_OFFSET_UNDERLINE = ELEMENT_STYLE_OFFSET_STRIKETHROUGH + 1;
export const ELEMENT_STYLE_OFFSET_INLINE_CODE = ELEMENT_STYLE_OFFSET_UNDERLINE + 1;
export const ELEMENT_STYLE_OFFSET_BACKGROUND_COLOR = ELEMENT_STYLE_OFFSET_INLINE_CODE + 1;
export const ELEMENT_STYLE_OFFSET_TEXT_COLOR = ELEMENT_STYLE_OFFSET_BACKGROUND_COLOR + 5;

export const ELEMENT_STYLE_MASK_BOLD: number = 1;
export const ELEMENT_STYLE_MASK_ITALIC = 1 << ELEMENT_STYLE_OFFSET_ITALIC;
export const ELEMENT_STYLE_MASK_STRIKETHROUGH = 1 << ELEMENT_STYLE_OFFSET_STRIKETHROUGH;
export const ELEMENT_STYLE_MASK_UNDERLINE = 1 << ELEMENT_STYLE_OFFSET_UNDERLINE;
export const ELEMENT_STYLE_MASK_INLINE_CODE = 1 << ELEMENT_STYLE_OFFSET_INLINE_CODE;
const COLER_MASK = Math.pow(2, 6) - 1;
export const ELEMENT_STYLE_MASK_BACKGROUND_COLOR = COLER_MASK << ELEMENT_STYLE_OFFSET_BACKGROUND_COLOR;
export const ELEMENT_STYLE_MASK_TEXT_COLOR = COLER_MASK << ELEMENT_STYLE_OFFSET_TEXT_COLOR;

const ALIGN_CENTER = Math.pow(2, 28);
const ALIGN_RIGHT = Math.pow(2, 29);
const ALIGN_MASK = ALIGN_CENTER | ALIGN_RIGHT;

export const getAlign = (style_: number) => {
  switch (style_ & ALIGN_MASK) {
    case ALIGN_CENTER:
      return 'center';
    case ALIGN_RIGHT:
      return 'right';
    default:
      return 'left';
  }
};
